{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">财务管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide"  id="currentTable" lay-filter="currentTable"></table>
        </div>
    </div>

</div>


<style>
    #layui-input-search{
        display: none;
    }
</style>


<script type="text/html" id="barTool">

    {{#  if(d.status == 0){ }}
    <a href='{:url("check")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-rebate {:$auth->check('rebate.index/del')?'':'layui-hide'}">结账</i></a>
    {{#  } }}

    <a href='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs {:$auth->check('rebate.index/edit')?'':'layui-hide'}" title="查看详情">查看详情</a>

<!--    <a href='{:url("del")}?id={{ d.id }}'-->
<!--       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('rebate.index/del')?'':'layui-hide'}">删除</i></a>-->


</script>

{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;
        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            rebate_url: '{:url("rebate")}',
            modify_url: '{:url("multi")}',

        };




        $(document).on('click', '.layui-tr-rebate', function() {
            var that = $(this),
                tableId = $(this).data('table'),
                href = !that.attr('data-href') ? that.attr('href') : that.attr('data-href');

            tables = layui.table;
            tableId = tableId || init.table_render_id;
            layer.confirm('确定结账吗？', { icon: 3, title: '提示信息' }, function(index) {
                if (!href) {
                    notice.info({ message: '请设置data-href参数' });
                    return false;
                }
                $.post(href, function(res) {
                    if (res.code == 1) {
                        notice.success({ message: res.msg });
                        tableId && tables.reload(tableId);
                    } else {
                        notice.error({ message: res.msg });
                    }
                });
                layer.close(index);
            });
            return false;
        });


        table.render({
            init: init,
            toolbar: ['refresh'],
            searchInput:false,
            url: '{:url("index")}',
            cols: yznTable.formatCols([
                [
                    {field: 'id', width: 80, title: 'ID',fieldAlias:'rebate_log.id',},
                    {field: 'day', title: '日期', search: 'range'},
                    {field: 'user.nickName', align: 'center', title: '昵称', searchOp: 'like'},
                    {field: 'money', align: 'center', title: '单价', searchOp: 'like'},
                    {field: 'video_num', title: '当日观看次数', search: false},
                    {field: 'total_money', title: '当日收入', search: false},
                    {field: 'alipay.real_name', title: '真实姓名'},
                    {field: 'alipay.account', title: '收款账号'},
                    { field: 'status',align:'center',fieldAlias:'rebate_log.status', title: '状态',templet: yznTable.formatter.label,selectList:{0:'未提现',1:'已提现'}},
                    {fixed: 'right', align: 'center', width: 180, title: '操作', toolbar: '#barTool'}

                ]
            ], init),
            page: {}
        });
        yznTable.bindevent();
    });




</script>
{/block}

